<script setup lang="ts">
import { reactive } from 'vue'
import {
  NForm,
  NFormItem,
  NInputNumber,
  NColorPicker,
  NScrollbar,
  NButton,
  NGrid,
  NGi
} from 'naive-ui'
import SettingService from '@/services/setting.service'

const settingService = new SettingService()

const crossSetting = reactive({ ...settingService.crossConfig })

function onSave() {
  settingService.saveCorss(crossSetting)
}
</script>

<template>
  <div class="cross-setting">
    <n-form label-width="60" label-placement="left" size="large">
      <n-grid cols="24" x-gap="15" y-gap="0">
        <n-gi span="12">
          <n-form-item label="颜色" path="color">
            <n-color-picker v-model:value="crossSetting.color" :show-alpha="false" />
          </n-form-item>
        </n-gi>
        <n-gi span="12">
          <n-form-item label="大小" path="size">
            <n-input-number :show-button="false" v-model:value="crossSetting.size" />
          </n-form-item>
        </n-gi>
        <n-gi span="12">
          <n-form-item label="线宽" path="width">
            <n-input-number :show-button="false" v-model:value="crossSetting.width" />
          </n-form-item>
        </n-gi>
        <n-gi span="12">
          <n-form-item label="间隔" path="gap">
            <n-input-number :show-button="false" v-model:value="crossSetting.gap" />
          </n-form-item>
        </n-gi>
        <n-gi span="12">
          <n-form-item label="X偏移" path="offsetX">
            <n-input-number :show-button="false" v-model:value="crossSetting.offsetX" />
          </n-form-item>
        </n-gi>
        <n-gi span="12">
          <n-form-item label="Y偏移" path="offsetY">
            <n-input-number :show-button="false" v-model:value="crossSetting.offsetY" />
          </n-form-item>
        </n-gi>
      </n-grid>
    </n-form>
    <div class="actions">
      <n-button type="primary" @click="onSave">保存</n-button>
    </div>
  </div>
</template>

<style scoped lang="less">
.cross-setting {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  .n-form {
    flex-grow: 1;
    overflow: hidden;
    padding: 5px 15px;
    :deep(.n-input-number) {
      width: 100%;
    }
  }
  .actions {
    padding: 8px;
    box-shadow: 0 0 1px 0 #DDD;
    display: flex;
    justify-content: flex-end;
  }
}
</style>
